package com.xunji.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xunji.user.entity.RoleMenu;
import com.xunji.user.mapper.RoleMenuMapper;
import com.xunji.user.service.RoleMenuService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuService {

    @Override
    public List<RoleMenu> getByRoleIds(List<String> roles) {
        QueryWrapper<RoleMenu> qw = new QueryWrapper<RoleMenu>().in("role_id",roles);
        return this.list(qw);
    }

    @Override
    public void batchSave(List<RoleMenu> roleMenus) {
        this.saveBatch(roleMenus);
    }

    @Override
    public void deleteByRoleId(String roleId) {
        LambdaQueryWrapper<RoleMenu> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(RoleMenu::getRoleId, roleId);
        remove(wrapper);
    }
}
